package com.web3.management.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * 账号专属配置实体类
 *
 * @author Web3 Management Team
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "account_configs")
public class AccountConfig extends BaseEntity {

    /**
     * 关联账号ID
     */
    @Column(name = "account_id", nullable = false)
    private Integer accountId;

    /**
     * 配置名称
     */
    @Column(name = "config_name", length = 100, nullable = false)
    private String configName;

    /**
     * 项目名称
     */
    @Column(name = "project_name", length = 100, nullable = false)
    private String projectName;

    /**
     * 基础资产代码
     */
    @Column(name = "base_asset", length = 50, nullable = false)
    private String baseAsset;

    /**
     * 报价资产代码
     */
    @Column(name = "quote_asset", length = 50, nullable = false)
    private String quoteAsset = "USDT";

    /**
     * 区块链ID
     */
    @Column(name = "chain_id", nullable = false)
    private Integer chainId = 56;

    /**
     * 合约地址
     */
    @Column(name = "contract_address", nullable = false)
    private String contractAddress;

    /**
     * 购买金额
     */
    @Column(name = "buy_amount", precision = 18, scale = 8)
    private BigDecimal buyAmount = BigDecimal.ZERO;

    /**
     * 目标购买报价
     */
    @Column(name = "target_buy_quote", precision = 18, scale = 8)
    private BigDecimal targetBuyQuote = BigDecimal.ZERO;

    /**
     * 是否启用代理：1启用，0禁用
     */
    @Column(name = "proxy_enabled")
    private Integer proxyEnabled = 0;

    /**
     * 代理配置JSON
     */
    @Lob
    @Column(name = "proxy_config")
    private String proxyConfig;

    /**
     * 通知回调URL
     */
    @Column(name = "notify_url", length = 500)
    private String notifyUrl;

    /**
     * 自定义配置JSON字段（滑点、Gas等）
     */
    @Lob
    @Column(name = "custom_config")
    private String customConfig;

    /**
     * 是否激活：1激活，0未激活
     */
    @Column(name = "is_active")
    private Integer isActive = 0;

    /**
     * 配置状态：1正常，0禁用
     */
    @Column(name = "status")
    private Integer status = 1;

    /**
     * 配置备注
     */
    @Lob
    @Column(name = "remark")
    private String remark;

    /**
     * 关联的账号实体
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "account_id", insertable = false, updatable = false)
    private Account account;
}